package io.ouka.jvm.hotspot.selfread.domain;

import io.ouka.jvm.hotspot.selfread.InstanceKlass;

import java.util.Arrays;

/**
 * @author ouka
 * MethodInfo
 */
public class MethodInfo {
    private InstanceKlass instanceKlass;
    private int accessFlag;
    private int nameIndex;
    private int descriptorIndex;
    private int attributeCount;
    private CodeAttribute[] codeAttributes;

    public InstanceKlass getInstanceKlass() {
        return instanceKlass;
    }

    public void setInstanceKlass(InstanceKlass instanceKlass) {
        this.instanceKlass = instanceKlass;
    }

    public void setCodeAttributes(CodeAttribute[] codeAttributes) {
        this.codeAttributes = codeAttributes;
    }

    public CodeAttribute[] getCodeAttributes() {
        return codeAttributes;
    }

    public int getAccessFlag() {
        return accessFlag;
    }

    public void setAccessFlag(int accessFlag) {
        this.accessFlag = accessFlag;
    }

    public int getNameIndex() {
        return nameIndex;
    }

    public void setNameIndex(int nameIndex) {
        this.nameIndex = nameIndex;
    }

    public int getDescriptorIndex() {
        return descriptorIndex;
    }

    public void setDescriptorIndex(int descriptorIndex) {
        this.descriptorIndex = descriptorIndex;
        this.codeAttributes = new CodeAttribute[descriptorIndex];
    }

    public int getAttributeCount() {
        return attributeCount;
    }

    public void setAttributeCount(int attributeCount) {
        this.attributeCount = attributeCount;
    }

    @Override
    public String toString() {
        return "MethodInfo{" +
                "accessFlag=" + accessFlag +
                ", nameIndex=" + nameIndex +
                ", descriptorIndex=" + descriptorIndex +
                ", attributeCount=" + attributeCount +
                ", codeAttributes=" + Arrays.toString(codeAttributes) +
                '}';
    }
}
